require 'image'
require 'setup'


LED_POWER=12
gpio.mode(LED_POWER,gpio.OUTPUT)
gpio.write(LED_POWER,gpio.HIGH)

PC_POWER=1
gpio.mode(PC_POWER,gpio.OUTPUT)
--gpio.write(PC_POWER,gpio.LOW)


setspi()
settouch()

clean_screen()

draw_powerbtn()
gpio.trig(irq_pin, "down", function()
    x,y=xpt2046.getPositionAvg()
    sq=10000-(x-120)*(x-120)-(y-160)*(y-160)
    if(sq>0)then
        draw_powerbtn_on()
        gpio.write(PC_POWER,1)
        tmr.alarm(6, 20, tmr.ALARM_SINGLE, function()
            gpio.write(PC_POWER,0)
            draw_powerbtn()
        end )
   
    end
end)
